package 第五轮工作.中原工学院;

import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;

import java.io.IOException;

public class ZYGU {
    public static void main(String[] args) throws IOException {
        String url = "https://jdxy.zut.edu.cn/info/1212/3882.htm";
        Connection connect = Jsoup.connect(url);
        Document post = connect.post();
        for (Element firstRow : post.getElementsByClass("v_news_content")) {
            for (Element element : firstRow.getElementsByTag("tr")) {
                for (Element td : element.getElementsByTag("td")) {
                    if (!td.getElementsByTag("a").text().trim().equals("")) {

                        Connection connect1 = Jsoup.connect("https://jdxy.zut.edu.cn/info/" + td.getElementsByTag("a").attr("href").substring(3));
                        Document post1 = connect1.post();
                        for (Element mainContit : post1.getElementsByClass("v_news_content")) {
                            int size = mainContit.getElementsByTag("p").size();
                            if (mainContit.getElementsByTag("p").get(size - 4).text().startsWith("Email")) {
                                System.out.println(mainContit.getElementsByTag("p").get(size - 4).text());
                                System.out.println(mainContit.getElementsByTag("p").get(1).text());
                            }
                        }

                    }
                }

            }
        }

    }
}
